<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false"%>
<%@include file="/common/skins/skin0/component.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%--
- Author(s): Administrator
- Date: 2018-04-02 19:08:03
- Description:
    --%>
<head>
<title>Bug录入</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="<%=request.getContextPath()%>/common/nui/nui.js"
	type="text/javascript">
	
</script>
</head>
<style>
.form_label {
	font-size: 12px;
}
</style>
<body>
	<!-- 标识页面是查看(query)、修改(edit)、新增(add) -->
	<input name="pageType" class="nui-hidden" />
	<div id="dataform1" style="padding-top: 5px;">
		<!-- hidden域 -->
		<input class="nui-hidden" name="zhmybug.bugId" />
		<table style="width: 100%; height: 15%; table-layout: fixed;"
			class="nui-form-table">
			<tr>
				<td class="form_label">bug标题:</td>
				<td colspan="1"><input class="nui-textbox" required="true"
					vtype="maxLength:10" name="zhmybug.bugTitle" /></td>

			</tr>

			<tr>
				<!-- <td class="form_label">bug进度:</td>
				<td colspan="1"><input class="nui-dictcombobox"
					dictTypeId="TASK_STATUS" name="zhmybug.bugStatus" /></td> -->
				<td class="form_label">bug紧急程度:</td>
				<td colspan="1"><input class="nui-dictcombobox" required="true"
					dictTypeId="URGENT_DEGREE" name="zhmybug.bugLevel" /></td>
			</tr>

			<tr>
				<td class="form_label">bug所属项目:</td>
				<td colspan="1"><input id="lookup2" required="true" onvaluechanged="onDeptChanged"
					name="zhmybug.zhmyProject.projectId" class="nui-lookup"
					style="width: 125px;" textField="projectName"
					valueField="projectId" popupWidth="auto" popup="#gridPanel"
					grid="#datagrid1" multiSelect="false" /></td>	
						 
			<tr>
				<td class="form_label">bug接收人:</td>
				<td colspan="1">
				
				<input id="lookup21" name="zhmybug.bugSendee"
					class="nui-lookup" style="width: 125px;" textField="userId"
					valueField="userId" popupWidth="auto" popup="#gridPanel1"
					grid="#datagrid11" multiSelect="false" /> 
					
					</td>
					
			<tr>
			<td class="form_label">bug所属版本:</td>
				<td colspan="1"><input id="lookup3" required="true"
				
					name="zhmybug.zhmyVersionChange.vcId" class="nui-lookup"
					style="width: 125px;" textField="vcVersionNumber"
					valueField="vcId" popupWidth="auto" popup="#gridPanel3"
					grid="#datagrid3" multiSelect="false" /></td>
			</td>



				<td class="form_label"></td>
				<td colspan="1"><a><button
							style='margin: 2px; background: #008cba; color: #fff; text-align: center; display: inline-block; border-radius: 8px; padding: 4px 10px; border: none;'
							onclick='onOk()'>保存</button></a></td>
			</tr>



		</table>
		<!-- <td class="form_label">bug内容:</td>
				<td colspan="1"><div>
		       <div style="width: 100%; height: 80%;">
				<w:richtext id="id1" name="zhmybug.bugContent2"
					property="zhmybug.bugContent2" width="100%" height="300" />
			</div></div></td> -->


		<div style="width: 100%; height: 80%;">
			<div>bug描述:</div>
			
			<div>
				<w:richtext id="id1" name="zhmybug.bugContent2"
					property="zhmybug.bugContent2" width="100%" height="300" />
			</div>







			<div class="nui-toolbar" style="padding: 0px;"
				borderStyle="border:0;">
				<table width="100%">
					<tr>
						<!-- <td style="text-align: center;" colspan="4"><a
						class="nui-button" iconCls="icon-save" onclick="onOk()"> 保存 </a> <span
						style="display: inline-block; width: 25px;"> </span> <a
						class="nui-button" iconCls="icon-cancel" onclick="onCancel()">
							取消 </a></td> -->

					</tr>
				</table>
			</div>
		</div>
		<!--  look up  -->
		<div id="gridPanel" class="nui-panel" title="header"
			iconCls="icon-add" style="width: 450px; height: 250px;"
			showToolbar="true" showCloseButton="true" showHeader="false"
			bodyStyle="padding:0" borderStyle="border:0">
			<div property="toolbar"
				style="padding: 5px; padding-left: 8px; text-align: center;">
				<div style="float: left; padding-bottom: 2px;">
					<span>项目名称:</span> <input id="keyText" class="nui-textbox"
						style="width: 160px;" onenter="onSearchClick1" /> <a
						class="nui-button" onclick="onSearchClick1">查询</a> <a
						class="nui-button" onclick="onClearClick1">清除</a>
				</div>
				<div style="float: right; padding-bottom: 2px;">
					<a class="nui-button" onclick="onCloseClick1">关闭</a>
				</div>
				<div style="clear: both;"></div>
			</div>
			<div id="datagrid1" class="nui-datagrid"
				style="width: 100%; height: 100%;" borderStyle="border:0"
				showPageSize="false" showPageIndex="false" dataField="orgs"
				url="com.zhmy.xmgl.bug.zhmybugbiz.getProjectName.biz.ext">
				<div property="columns">
					<div type="checkcolumn"></div>
					<div field="projectId" width="120" headerAlign="center"
						allowSort="true">项目编码</div>
					<div field="projectName" width="120" headerAlign="center"
						allowSort="true">项目名称</div>
				</div>
			</div>
		</div>
		
		
		
		<div id="gridPanel3" class="nui-panel" title="header"
			iconCls="icon-add" style="width: 450px; height: 250px;"
			showToolbar="true" showCloseButton="true" showHeader="false"
			bodyStyle="padding:0" borderStyle="border:0">
			<div property="toolbar"
				style="padding: 5px; padding-left: 8px; text-align: center;">
				<div style="float: left; padding-bottom: 2px;">
					<span>版本名称:</span> <input id="keyText4" class="nui-textbox"
						style="width: 160px;" onenter="onSearchClick3" /> <a
						class="nui-button" onclick="onSearchClick3">查询</a> <a
						class="nui-button" onclick="onClearClick3">清除</a>
				</div>
				<div style="float: right; padding-bottom: 2px;">
					<a class="nui-button" onclick="onCloseClick3">关闭</a>
				</div>
				<div style="clear: both;"></div>
			</div>
			<div id="datagrid3" class="nui-datagrid"
				style="width: 100%; height: 100%;" borderStyle="border:0"
				showPageSize="false" showPageIndex="false" dataField="orgs"
				url="com.zhmy.xmgl.bug.zhmybugbiz.getBugVersionNumber.biz.ext">
				<!-- com.zhmy.xmgl.bug.zhmybugbiz.getBugVersionNumber.biz.ext -->
				<div property="columns">
					<div type="checkcolumn"></div>
					<div field="vcId" width="120" headerAlign="center"
						allowSort="true">版本ID</div>
					<div field="vcVersionNumber" width="120" headerAlign="center"
						allowSort="true">版本号</div>
				</div>
			</div>
		</div>
		
		


		<!--  look up 3 -->
	<div id="gridPanel1" class="nui-panel" title="header"
		iconCls="icon-add" style="width: 450px; height: 250px;"
		showToolbar="true" showCloseButton="true" showHeader="false"
		bodyStyle="padding:0" borderStyle="border:0">
		<div property="toolbar"
			style="padding: 5px; padding-left: 8px; text-align: center;">
			<div style="float: left; padding-bottom: 2px;">
				<span>接收人:</span> <input id="keyText1" class="nui-textbox"
					style="width: 160px;" onenter="onSearchClick" /> <a
					class="nui-button" onclick="onSearchClick">查询</a> <a
					class="nui-button" onclick="onClearClick">清除</a>
			</div>
			<div style="float: right; padding-bottom: 2px;">
				<a class="nui-button" onclick="onCloseClick">关闭</a>
			</div>
			<div style="clear: both;"></div>
		</div>
		<div id="datagrid11" class="nui-datagrid"
			style="width: 100%; height: 100%;" borderStyle="border:0"
			showPageSize="false" showPageIndex="false" dataField="orgs"
			url="com.zhmy.xmgl.zhmyprojectmanage.getPeopleListOfProject.biz.ext?projectid=1">
			<div property="columns">
				<div type="checkcolumn"></div>
				<div field="userId" width="120" headerAlign="center"
					allowSort="true">姓名</div>
			</div>
		</div>
	</div>
		<script type="text/javascript">
			nui.parse();
			
			function onDeptChanged(e) {
			//console.log("onDeptChanged");
			var projectid = nui.getbyName("zhmybug.zhmyProject.projectId").getValue();
			outProjectid = projectid;
			

		    var url = "com.zhmy.xmgl.zhmyprojectmanage.getPeopleListOfProject.biz.ext?projectid="+projectid;
		    nui.get("datagrid11").setUrl(url);
		    onSearchClick();
		    onSearchClick3();
		   }
			
			
			

			function saveData() {
				var content = $id("id1").getValue();
				var desc = content;

				var form = new nui.Form("#dataform1");
				form.setChanged(false);
				//保存
				var urlStr = "com.zhmy.xmgl.bug.zhmybugbiz.addZhmyBugs.biz.ext";
				var pageType = nui.getbyName("pageType").getValue();//获取当前页面是编辑还是新增状态
				//编辑
				if (pageType == "edit") {
					urlStr = "com.zhmy.xmgl.bug.zhmybugbiz.updateZhmyBugs.biz.ext";
				}
				form.validate();
				if (form.isValid() == false)
					return;

				var data = form.getData(false, true);

				var temp = data.zhmybug.bugSendee;
				data.zhmybug.bugSendee = temp || ' ';

				data.zhmybug.bugContent = desc;
				var json = nui.encode(data);

				$.ajax({
					url : urlStr,
					type : 'POST',
					data : json,
					cache : false,
					contentType : 'text/json',
					success : function(text) {
						var returnJson = nui.decode(text);
						if (returnJson.exception == null) {
							CloseWindow("saveSuccess");
							nui.alert("新增bug成功");
						} else {
							nui.alert("保存失败", "系统提示", function(action) {
								if (action == "ok" || action == "close") {
									//CloseWindow("saveFailed");
								}
							});
						}
					}
				});
			}

			//页面间传输json数据
			function setFormData(data) {
				//跨页面传递的数据对象，克隆后才可以安全使用
				var infos = nui.clone(data);

				//保存list页面传递过来的页面类型：add表示新增、edit表示编辑
				nui.getbyName("pageType").setValue(infos.pageType);

				//如果是点击编辑类型页面
				if (infos.pageType == "edit") {
					var json = infos.record;
					
					var form = new nui.Form("#dataform1");//将普通form转为nui的form
					form.setData(json);
					form.setChanged(false);
					nui.get("lookup2").setText(
							json.zhmybug.zhmyProject.projectName);
					/* nui.get("lookup21").setText(
							json.CAP_PARTYAUTH.CapPartyauth.partyId); */
					nui.get("lookup21").setText(json.zhmybug.bugSendee);
				    $id("id1").setValue(json.zhmybug.bugContent);		
				}
			}

			//关闭窗口
			function CloseWindow(action) {
				if (action == "close" && form.isChanged()) {
					if (confirm("数据被修改了，是否先保存？")) {
						saveData();
					}
				}
				if (window.CloseOwnerWindow)
					return window.CloseOwnerWindow(action);
				else
					window.close();
			}

			//确定保存或更新
			function onOk() {
				saveData();
			}

			//取消
			function onCancel() {
				CloseWindow("cancel");
			}

			var grid1 = nui.get("datagrid1");
			var keyText = nui.get("keyText");
			grid1.load();
			function onSearchClick1(e) {
				grid1.load({
					key : keyText.value
				});
			}

			function onCloseClick1(e) {
				var lookup2 = nui.get("lookup2");
				lookup2.hidePopup();
			}
			function onClearClick1(e) {
				var lookup2 = nui.get("lookup2");
				lookup2.deselectAll();
			}

			function onClenrClick1() {
				var lookup2 = nui.get("lookup2");
				lookup2.deselectAll();
			}



			var grid = nui.get("datagrid11");
			var keyText1 = nui.get("keyText1");
			grid.load();
			function onSearchClick(e) {
				grid.load({
					key : keyText1.value
				});
			}

			function onCloseClick(e) {
				var lookup2 = nui.get("lookup21");
				lookup2.hidePopup();
			}
			function onClearClick(e) {
				var lookup2 = nui.get("lookup21");
				lookup2.deselectAll();
			}

			function onClenrClick() {
				var lookup2 = nui.get("lookup21");
				lookup2.deselectAll();
			}
			
			
			
			
			
			var grid4 = nui.get("datagrid3");
			var keyText4 = nui.get("keyText4");
			grid4.load(
			{
				key : keyText4.value ,
				projectid: outProjectid
			});
			function onSearchClick3(e) {
				grid4.load({
					key : keyText4.value ,
					projectid: outProjectid
				});
			}

			function onCloseClick3(e) {
				var lookup2 = nui.get("lookup3");
				lookup2.hidePopup();
			}
			function onClearClick3(e) {
				var lookup2 = nui.get("lookup3");
				lookup2.deselectAll();
			}

			function onClenrClick3() {
				var lookup2 = nui.get("lookup3");
				lookup2.deselectAll();
			}
			
			
			
			
			
			
			
		</script>
</body>
</html>
